package com.gakj.truck.third.api.ouman;

import com.alibaba.fastjson.JSONObject;
import com.gakj.truck.third.core.utils.HttpToolkit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by gc on 2016/5/10.
 */
@Component
public class OumanService {

    @Value("${ouman_truck_url}")
    String ouman_truck_list;

    @Value("${ouman_user_url}")
    String ouman_user_url;

    @Value("${ouman_inquiry_url}")
    String ouman_truck_inquiry_url;


    public JSONObject getOumanTruckList(int day) {
        String url = MessageFormat.format(ouman_truck_list, day);
        Map<String, String> heads = new HashMap<>();
        heads.put("Content-Type", "application/json;charset=utf-8");
        heads.put("Accept", "application/json");
        JSONObject result = HttpToolkit.Get(url, null);
        return result;
    }

    /**
     * 测试用户名: 13696384060 密码: 111111
     *
     * @param loginName
     * @param mobile
     * @param password
     * @return
     */
    public JSONObject CheckUser(String loginName, String mobile, String password) {
        String url = MessageFormat.format(ouman_user_url, loginName, mobile, password);
        JSONObject result = HttpToolkit.Get(url, null);
        return result;
    }

    public JSONObject getTruckInquiryList(int day) {
        String url = MessageFormat.format(ouman_truck_inquiry_url, day);
        JSONObject result = HttpToolkit.Get(url, null);
        return result;
    }

}
